﻿using System;

namespace Yyd.Share.Base
{
    /// <summary>
    /// 逻辑处理异常
    /// </summary>
    public class OperationException : Exception
    {
        public OperationException(string message) : base(message)
        {
        }

        public OperationException(int statusCode, string errorMessage) : base(errorMessage)
        {
            StatusCode = statusCode;
            ErrorCode = StatusCode.ToString();
        }

        public OperationException(int statusCode, string errorCode, string errorMessage) : base(errorMessage)
        {
            StatusCode = statusCode;
            ErrorCode = errorCode;
        }

        public string ErrorCode { get; }
        public int StatusCode { get; }
    }

    public class OperationWithExtraDataException : OperationException
    {
        public OperationWithExtraDataException(int statusCode, string errorCode, string errorMessage,
            object exceptionData) : base(statusCode, errorCode, errorMessage)
        {
            ExceptionData = exceptionData;
        }

        public object ExceptionData { get; }
    }
}